{extend name="layout" /}
{block name="my_body"}
<div class="widgetbox box-inverse">
    <div class="widgetcontent wc1">

        <form id="form1" class="stdform" >


            <div class="par control-group">
                <label class="control-label" for="old_password">原密码</label>
                <div class="controls"><input type="password" name="old_password" id="old_password" class="input-xlarge" /></div>
            </div>

            <div class="par control-group">
                <label class="control-label" for="password">新密码</label>
                <div class="controls"><input type="password" name="password" id="password" class="input-xlarge" /></div>
            </div>

            <div class="par control-group">
                <label class="control-label" for="password_confirm">确认密码</label>
                <div class="controls"><input type="password" name="password_confirm" id="password_confirm" class="input-xlarge" /></div>
            </div>

            <p class="stdformbutton">
                <a class="btn btn-primary">提交</a>
            </p>
        </form>
    </div><!--widgetcontent-->
</div><!--widget-->
{/block}

{block name="my_js"}
<script>
    var url = "<?php echo url('base/Index/setPassword');?>";
    var jumpUrl = "<?php echo url('base/Index/index');?>";
    jQuery('.stdformbutton .btn').click(function(){
    var formData = jQuery("#form1").serialize();//序列化表格内容为字符串
            jQuery.ajax({
                type: 'POST',
                url: url,
                data: formData ,
                dataType: 'JSON',
                success: function(res){
                    if(res.code == 0)
                    {
                        window.location.href=jumpUrl;
                    }
                    else
                    {
                        var html = '<div class="widgetbox box-danger"><h4 class="widgettitle">错误提示 <a class="close">×</a> <a class="minimize">–</a></h4><div class="widgetcontent">'+res.msg+'</div></div>';
                        var h = jQuery(html);
                        jQuery(".widgetcontent").prepend(h);
                        window.setTimeout(function(){
                            h.remove();
                        },1000);
                    }
                }
            })
        }
    );
</script>
{/block}